package com.demo2do.fms.entity.supplier.common;

import com.demo2do.core.utils.Alias;

/**
 * 服务供方审核状态
 * 
 * @author Wy
 */
@Alias("SupplierAuditStatus")
public enum AuditStatus {
    
    EDITING("editing", "备选", false),
    
    AUDITING("auditing", "待审核", false),
    
    QUALIFIED("qualified", "合格", true),
    
    REJECTED("rejected", "驳回", false),
    
    CHANGEING("changeing", "变更申报", false),
    
    ONE_LEVEL_RECTIFY("one_level_rectify", "合格但I级单项整改中", true),
    
    TWO_LEVEL_RECTIFY("two_level_rectify", "合格但II、III级单项整改中", true),
    
    UNITE_RECTIFY("unite_rectify", "合格但综合整改中", true),
    
    MODIFIED_REJECTED("modified_rejected", "变更驳回", false);

    private String alias;
    
    private String description;
    
    private boolean rectify;

    /**
     * @param alias
     * @param description
     */
    private AuditStatus(String alias , String description) {
        this.alias = alias;
        this.description = description;
    }

    /**
     * 一般仓储供方显示
     * @return
     */
    public boolean canCommonStotageSupplierShow(){
        return this.equals(EDITING) || this.equals(QUALIFIED) || this.equals(UNITE_RECTIFY);
    }
    
    /**
     * @return
     */
    public boolean isEditing() {
        return this.equals(EDITING);
    }
    
    /**
     * @return
     */
    public boolean isAuditing() {
        return this.equals(AUDITING);
    }
    
    /**
     * 
     * @return
     */
    public boolean isQualified() {
        return this.equals(QUALIFIED);
    }
    
    /**
     * 
     * @return
     */
    public boolean isRejected() {
        return this.equals(REJECTED);
    }
    
    /**
     * 
     * @return
     */
    public boolean isUniteRectify() {
        return this.equals(UNITE_RECTIFY);
    }
    
    /**
     * 
     * @return
     */
    public boolean isTwoLevelRectify() {
        return this.equals(TWO_LEVEL_RECTIFY);
    }
    
    /**
     * 
     * @return
     */
    public boolean isOneLevelRectify() {
        return this.equals(ONE_LEVEL_RECTIFY);
    }
    
    /**
     * 
     * @return
     */
    public boolean couldChange() {
        return this.isOneLevelRectify() || this.isTwoLevelRectify() || this.isUniteRectify();
    }
    
    /**
     * @param alias
     * @param description
     * @param rectify
     */
    private AuditStatus(String alias, String description, boolean rectify) {
        this.alias = alias;
        this.description = description;
        this.rectify = rectify;
    }

    /**
     * 
     * @param alias
     * @return
     */
    public static AuditStatus aliasOf(String alias){
        
        for(AuditStatus auditStatus : AuditStatus.values()){
            if(auditStatus.getAlias().equals(alias)){
                
                return auditStatus;
            }
        }
        return null;
    }
    
    /**
     * @return
     */
    public int getOrdinal() {
        return this.ordinal();
    }
    
    /**
     * 
     * @return  alias
     */
    public String getAlias() {
        return alias;
    }
    
    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * @return
     */
    public boolean isRectify() {
        return rectify;
    }

}
